package sg.edu.nus.iss.billing.model.complaint;

import java.util.Comparator;

import sg.edu.nus.iss.billing.BillingConstants.SearchSortBy;
import sg.edu.nus.iss.billing.model.complaint.Complaint;

/**
 * @author Yeo Hee Ling, BeeHong, EngKhoon
 *
 */
public class ComplaintSorter implements Comparator<Complaint> {
	
	private SearchSortBy sortBy;
	
	public ComplaintSorter(SearchSortBy sortBy) {
		this.sortBy = sortBy;
	}
	
	public int compare(Complaint complaint1, Complaint complaint2) {
		int res = 0;
		
		if(SearchSortBy.ACCOUNT_NO == sortBy)
			return (complaint1.getAccountNo().compareTo(complaint2.getAccountNo()));
		if(SearchSortBy.COMPLAINT_NO == sortBy)
			return (complaint1.getComplaintId().compareTo(complaint2.getComplaintId()));
		if(SearchSortBy.COMPLAINT_STATUS == sortBy)
			return (complaint1.getComplaintStatus().compareTo(complaint2.getComplaintStatus()));
		
		return res;
	}

}
